<template>
  <div>
    <el-table
      :data="pi.records"
      :stripe="true"
      style="...">
      <el-table-column
        prop="id"
        label="学号">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名">
      </el-table-column>
      <el-table-column
        label="职务">
<!--        自定义目标-->
        <template slot-scope="scope">
          <div v-if="scope.row.job=1">班长</div>
          <div v-if="scope.row.job=2">组长</div>
          <div v-if="scope.row.job=3">学员</div>
        </template>
      </el-table-column>

      <el-table-column
        label="专业">
        <!--        自定义目标-->
        <template slot-scope="scope">
          <div v-if="scope.row.job=1">金融</div>
          <div v-if="scope.row.job=2">计算机</div>
          <div v-if="scope.row.job=3">会计</div>
        </template>
      </el-table-column>

      <el-table-column
        prop="grade"
        label="班级">
      </el-table-column>
      <el-table-column
        label="性别">
        <template slot-scope="scope">
<!--          拿到当前行的数据-->
          {{scope.row.sex==0?"女":"男"}}
        </template>
      </el-table-column>
      <el-table-column
        prop="brithday"
        label="生日">
      </el-table-column>
      <el-table-column
        prop="tel"
        label="电话">
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <router-link :to="{path:'/manager/stu/',query:{stuId:scope.row.id,stuName:scope.row.name}}">
            <el-button>查看</el-button>
          </router-link>
        </template>
      </el-table-column>

    </el-table>
    <el-pagination
      layout="sizes,prev,pager,next,jumper,->,total"
      :total="pi.total"
      :page-size.sync="pi.size"
      :page-sizes="[2,5,10,50]"
      :current-page.sync="pi.current"
      :pager-count="9"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      background>
    </el-pagination>
    <router-view/>
  </div>
</template>

<script>
export default {
  name: "stuList",
    data(){
        return{
          pi:{}
        }
    },
    created() {
      //发出ajax请求后端代码
      this.Fy(1,5);
    },
    methods:{
      handleSizeChange(size){
        //再次调用ajax到后台取数据
        this.Fy(this.pi.current,size)
      },
      handleCurrentChange(page){
        this.Fy(page,this.pi.size);
      },
      Fy(pageNum,pageSize){
        this.axios.get("/student/selects/"+pageNum+"/"+pageSize).then((resp)=>{
          this.pi=resp.data;
          console.log(this.pi)
        });
      }

    }
}
</script>

<style scoped>

</style>
